<template>
  <div>
<h2>登录页面</h2>
<table class="table table-bordered=1">
  <tr>
    <td align="right">用户名</td>
    <td>
      <input type="text" v-model="state.name">
    </td>
  </tr>
  <tr>
    <td align="right">密码</td>
    <td>
      <input type="password" v-model="state.pwd">
    </td>
  </tr>
  <tr>
    <td align="right"></td>
    <td>
      <input type="button" value="登录" @click="login">
    </td>
  </tr>
</table>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import{reactive,toRefs,onMounted}from 'vue'
import { useRoute,useRouter } from 'vue-router';
const routr=useRoute();
const router=useRouter();
let data:any=reactive({
  state:{
    name:'',
    pwd:''
  }
})
let {state}=toRefs(data)
function login()
{
  let obj={
    name:state.value.name,
    pwd:state.value.pwd
  }
  if(state.value.name=="")
  {
    alert("用户名不能为空")
    return;
  }
  if(state.value.pwd=="")
  {
    alert("密码不能为空")
    return;
  }
  axios({
    url:'/api/Member/Login',
    method:'get',
    params:obj
  })
  .then(res=>{
    if(res.data.data!="")
  {
    alert("登录成功")
    router.push("../show")
  }
  else
  {
    alert("登录失败")
  }
  })
  .catch(err=>{

  })
}
</script>

<style scoped>

</style>